#pragma once
#include<vulkan/vulkan.hpp>
#include<vector>
#include<limits>
struct SwapChainSupportDetails
{
    vk::SurfaceCapabilitiesKHR capabilities;
    std::vector<vk::SurfaceFormatKHR> formates;
    std::vector<vk::PresentModeKHR> presentModes;

    vk::SurfaceFormatKHR chooseFormat(){
        if (formates.size()==1&& formates[0].format == vk::Format::eUndefined)
        {
            return {vk::Format::eR8G8B8A8Unorm,vk::ColorSpaceKHR::eSrgbNonlinear};
        }
        for(const auto &format :formates){
            if (format.colorSpace ==vk::ColorSpaceKHR::eSrgbNonlinear&& format.format == vk::Format::eR8G8B8A8Unorm )
            {
                return format;
            }
        }
        return formates[0];
    }
    vk::PresentModeKHR choosePresentMode(){
        vk::PresentModeKHR resutlt = vk::PresentModeKHR::eFifo;
        for(const auto &item  : presentModes)
        {
            if(item == vk::PresentModeKHR::eMailbox)
            {
                return item;
            }
            if (item == vk::PresentModeKHR::eImmediate)
            {
                resutlt = item;
            }
            
        }
        return resutlt;
    }
    vk::Extent2D chooseSwapExtent(uint32_t width,uint32_t height){
        if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max())   
        {
            return capabilities.currentExtent;
        }
        vk::Extent2D actualExtent2D = {
            std::max<uint32_t>(capabilities.minImageExtent.width,std::min<uint32_t>(capabilities.maxImageExtent.width,width)),
            height};
        return actualExtent2D;
    }
};